#ifndef FEATUREDATA_H
#define FEATUREDATA_H

#include "lib.h"
#include <vector>

using namespace std;

struct FeatureData
{
    uint8 id;
    int32 data;
    bool8 serverOnly;
};

typedef vector<FeatureData *> FeatureArray;

struct FeatureList
{
	uint8	level;
	FeatureArray array;
};

class Feature
{
    public:
        Feature();
        ~Feature();

        void update(uint8 id, int32 data, bool8 serverOnly = false);
        void updateLevel(uint8 level, uint8 id, int32 data, bool8 serverOnly = false);

        int32 getDataCount();
		int32 getDataCountLevel (uint8 level);
		int32 getAllDataCount();


        int32 getData(uint8 id);
        int32 getDataLevel(uint8 level, uint8 id);

        bool8 isServerOnly(uint8 id);
        bool8 isServerOnlyLevel(uint8 level, uint8 id);

        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        int32 getDataAt(int32 index);
        int32 getDataAtLevel(uint8 level, int32 index);

        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        int32 getIdAt(int32 index);
        int32 getIdAtLevel(uint8 level, int32 index);

		int32 getLevelCount();
		uint8 getLevelAt(int32 index);

        /**
         * The AT methods should used by something that needs
         * to iterate the subgame data.  All normal access should
         * be via id only.
         */
        bool8 isServerOnlyAt(int32 index);
        bool8 isServerOnlyAtLevel(uint8 level, int32 index);

        uint8 getClientOnlyDataSize();
        uint8 getClientOnlyDataSizeLevel(uint8 level);

		void setGameNum(int64 gameNum);
        int64 getGameNum();

		void setLevel (int32 level);
		int32 getLevel ();

		void clearAll ();

    private:
		enum {
			STARTINGLEVEL = 1,
		};


    	int64	m_gameNum;
		int32	m_level;

//        typedef vector<FeatureData *> FeatureArray;
        typedef vector<FeatureList *> FeatureArrayVec;
        FeatureArrayVec m_array;

        void add(uint8 id, int32 data, bool8 serverOnly = false);
		void addLevel(uint32 level, uint8 id, int32 data, bool8 serverOnly = false);

		FeatureArray* getFeatureArray(uint8 level);
};

#endif
